$(function()
{
	$(".icon").click(function()
	{
		$(".icon").removeClass("lightOff");
		$(this).addClass("lightOff");
		var light = $(".lightOff").attr("id");
		if(light == "newsBut")
		{
			$("#newsBut").css("box-shadow", "none");
			$("#newsBut").css("-moz-box-shadow", "none");
		}
		if(light == "mesBut")
		{
			$("#mesBut").css("box-shadow", "none");
			$("#mesBut").css("-moz-box-shadow", "none");
		}
		if(light == "frReqBut")
		{
			$("#frReqBut").css("box-shadow", "none");
			$("#frReqBut").css("-moz-box-shadow", "none");
		}
		$("#newsDialog").show("explode");
		var curNewId;
		$(".icon").removeClass("vara");
		$(this).addClass("vara");
		curNewId = $(".vara").attr("id");
		if(curNewId == "frReqBut")
		{
			$("#newsDialogTitle").html("Friendship requests");
			$("#newsDialogHeadless").load("friendRequests.php");
		}
		else
		if(curNewId == "newsBut")
		{
			$("#newsDialogTitle").html("News");
			$("#newsDialogHeadless").load("notification.php");
		}
		else
		if(curNewId == "advSearchBut")
		{
			$("#newsDialogTitle").html("Advanced search");
			$("#newsDialogHeadless").load("stakoSearchForm.php");
		}
		else
		if(curNewId = "mesBut")
		{
			$("#newsDialogTitle").html("New Messages");
			var to = $(".chatWindowHeader").attr("id");
			$.post("checkForNewMessagesFromOtherUsers.php", {opened : to}, function(data)
			{
				if(data!="HUI")
				{	
					$.post("showNewChatMessagesNotifications.php", {opened : to}, function(theData)
					{
						$("#newsDialogHeadless").html(theData);
					});
				}
			});
		}
	});
	$("#newsDialog").draggable({handle:"#newsDialogHeader"});
	$("#closeNews").click(function()
	{
		$("#newsDialog").hide("explode");
	});
});
































































